function playMusic(){
    // 初始化当前正在播放的音乐序号
    let currentIndex = 0;
    // 初始化播放状态, false暂停true播放
    let play = false;

    // 事件代理方式，将播放点击事件交给ul父元素处理
    let ulEle = document.getElementsByTagName('ul')[0];
    ulEle.onclick = function(){
        let e = event || window.event;
        let target  = e.target || e.srcElement;
        if(target.nodeName == 'IMG'){
            // 获取播放列表序号index
            let liEle = target.parentElement.parentElement.parentElement;
            let index  = liEle.id; 
            if(index != currentIndex){
                //暂停上一个正在播放音乐项，
                if(currentIndex != 0){
                    let oldLiEle = document.getElementById(currentIndex);
                    let imgEle = oldLiEle.lastElementChild.lastElementChild.firstElementChild;
                    imgEle.src='./image/pause.png';
                }
                //设置当前播放项为播放状态
                target.src='./image/play.png';
                play = true;
                currentIndex = index;
            }else{
                if(play){
                    play = false;
                    target.src='./image/pause.png';
                }else{
                    play = true;
                    target.src='./image/play.png';
                }
            }
        }
    }
}

playMusic();